﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SCSService;

namespace SCS.Core.Models.ModelsFontend
{
    public class ProductModel
    {
        #region "Config"
        public static System_Website GetWebsitebyDomain(string domain)
        {
            ConfigService configSvc = new ConfigService();
            return configSvc.GetWebsiteByDomain(domain);
        }
        #endregion

        #region "TypeProduct"

        public static List<Type_Product_Language> GetListTypeProductByParentId(int? typeID, int LanguageID, int siteGuid,int status)
        {
            //List Type Product with param is null
            ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductByParentNotParam(typeID, LanguageID, siteGuid, status);
        }

        public static Type_Product GetTypeProduct(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetTypeProduct(id);
        }

        public static Type_Product GetTypeProductByIdAndSiteGuid(int id,int siteGuid)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetTypeProductBysiteGuid(id, siteGuid);
        }

        public static List<Type_Product_Language> GetListTypeProductByParentIdAndParam(int? parentId, int languageID, int siteGuid, int? status, string param)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductByParentIDAndParam(null,status,null,parentId,param, languageID, siteGuid);
        }

        //public static IEnumerable<Type_Product> GetListTypeProduct()
        //{
        //    var list = GetListTypeProductByParentId(null);
        //    return (from p in list
        //            select p);
        //}

        #endregion

        #region "Product"
        public static List<Product_Language> GetListProductByTypeProduct(int? typeId, int LanguagesID, int siteGuid,int? status)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductByTypeProduct(typeId, LanguagesID, siteGuid,status);
        }

        public static List<Product_Language> GetListProductByTypeProductFilter(int? typeId, int LanguagesID, int siteGuid, int? status,List<Type_Property> listFilter)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductByTypeProductFilter(typeId, LanguagesID, siteGuid, status, listFilter);
        }

        public static Product GetProductByID(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetProduct(id);
        }

        public static Product_Language GetProductByIDAndSiteGuid(int id,int siteGuid,int languagesID)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetProductBySiteGuid(id, siteGuid,languagesID);
        }

        public static List<Product> GetListTopTenProduct(int LanguagesID, int siteGuid)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListTopTenProduct(LanguagesID, siteGuid);
        }

        public static List<Product> GetListProductSearchBasic(string searchText, int languageID, int siteGuid)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductSearchBasic(searchText, languageID, siteGuid);
        }

        public static List<Product_Language> GetListProductSearchCategory(string searchText,int? typeID, int languageID, int siteGuid)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductSearchCategory(searchText, typeID, languageID, siteGuid);
        }

        public static List<int> ListTypeProductIDManagerByProductID(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListTypeProductIdManageByProductID(id);
        }

        public static bool CheckTypePropertiesForProductByAbtract(int proid, string abtract, int siteGuid, int languageID)
        {
            ProductService proSvc = new ProductService();
            return proSvc.CheckTypePropertiesForProductByAbtract(proid,abtract,siteGuid,languageID);
        }

        public static List<Product_Type_Property> GetListProductTypePropertyByProductID(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductTypePropertyByProductID(id);
        }

        public static List<Type_Property> GetListTypePropertiesByProductID(int id, int languageId, int status)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListTypePropertiesByProductID(id,languageId,status);
        }

        public static List<Product_Property> GetListProductProperties(int? typeid, int? proId)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductProperties(typeid, proId);
        }
        #endregion

        #region "Product Price"
        public static long GetProductStockDetailByProductId(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetProductStockDetailByProductID(id, 1);
        }
        public static Product_Price GetProductPriceByProductId(int id,int? languageID,int? currencyID)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetProductPriceByProductID(id, languageID, currencyID);
        }
        public static List<Product_Price> GetListProductPriceByProductID(int id, int? languageID, int? currencyID)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductPriceByProductID(id, languageID, currencyID);
        }

        public static Discount GetDiscountByProductID(int id, int? languageID)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetDiscountByProductID(id, languageID);
        }

        public static List<Product_Item> GetListProductItemByProductID(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductItemByProductID(id);
        }

        public static int CreateProductItem(Product_Item items)
        {
            ProductService proSvc = new ProductService();
            return proSvc.CreateProductItem(items);
        }
        #endregion

        #region "Product Stock"
        public static long GetProductStockByProductId(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetProductStockByProductID(id,1);
        }

        public static List<Product_Stock> GetListProductStockByProductID(int id)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListProductStockByProductID(id, 1);
        }
       
        #endregion

        #region "Product Properties"
        public static List<System_Website_TypeProperty> GetListSystemWebsiteTypePropertiesBysiteGuid(int siteGuid)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListSystemWebsiteTypePropertiesBysiteGuid(siteGuid);
        }

        public static void CreateSystemWebsiteTypeProperties(System_Website_TypeProperty swt)
        {
             ProductService proSvc = new ProductService();
             proSvc.CreateSystemWebsiteTypeProperties(swt);
        }

        public static List<Type_Property> GetListFilterForTypeProduct(int? typeId, int languageID, int siteGuid)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListFilterForTypeProduct(typeId,languageID,siteGuid);
        }

        public static List<Type_Property> GetListTypePropertiesByParent(int parentId)
        {
            ProductService proSvc = new ProductService();
            return proSvc.GetListTypePropertiesByParent(parentId);
        }
        #endregion
    }
}